package admin.code.generator.util;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 *
 *@author Jack
 *2016年3月4日下午10:37:25
 */
public class ConnectionManager {

	public static Connection getConnection(String url, String user, String password) throws Exception {
		//		String url = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF8";
		//		String user = "root";
		//		String password = "heaven";
		Class.forName("com.mysql.jdbc.Driver");// 动态加载mysql驱动
		Connection conn = DriverManager.getConnection(url, user, password);
		return conn;
	}

	public static Connection getConnection() throws Exception {
		// read configuration file
		String url = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF8";
		String user = "root";
		String password = "heaven";
		Class.forName("com.mysql.jdbc.Driver");// 动态加载mysql驱动
		Connection conn = DriverManager.getConnection(url, user, password);
		return conn;
	}
}
